﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
using Enterprise.Model.Module;
using Enterprise.Infrastructure;
namespace Enterprise.Data.Module
{
    /// <summary>
    ///  系统模块操作方法
    /// </summary>
    public class ModuleData
    {
        /// <summary>
        ///  系统模块数据列表
        /// </summary>
        /// <returns></returns>
        public List<ModuleEntity> ModuleList()
        {
            List<ModuleEntity> list = new List<ModuleEntity>();
            string cmd = "Select * from SYS_MODULE";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                ModuleEntity entity = new ModuleEntity();
                if (!Convert.IsDBNull(dr["MODULEID"])) entity.MODULEID = Convert.ToInt32(dr["MODULEID"]);
                if (!Convert.IsDBNull(dr["PBGROUP"])) entity.PBGROUP = Convert.ToString(dr["PBGROUP"]);
                if (!Convert.IsDBNull(dr["MCODE"])) entity.MCODE = Convert.ToString(dr["MCODE"]);
                if (!Convert.IsDBNull(dr["MNAME"])) entity.MNAME = Convert.ToString(dr["MNAME"]);
                if (!Convert.IsDBNull(dr["MPARENTID"])) entity.MPARENTID = Convert.ToInt32(dr["MPARENTID"]);
                if (!Convert.IsDBNull(dr["MROOTID"])) entity.MROOTID = Convert.ToInt32(dr["MROOTID"]);
                if (!Convert.IsDBNull(dr["MIMAGE"])) entity.MIMAGE = Convert.ToString(dr["MIMAGE"]);
                if (!Convert.IsDBNull(dr["MSINGLE"])) entity.MSINGLE = Convert.ToInt32(dr["MSINGLE"]);
                if (!Convert.IsDBNull(dr["MTARGET"])) entity.MTARGET = Convert.ToString(dr["MTARGET"]);
                if (!Convert.IsDBNull(dr["MURL"])) entity.MURL = Convert.ToString(dr["MURL"]);
                if (!Convert.IsDBNull(dr["MDELETE"])) entity.MDELETE = Convert.ToString(dr["MDELETE"]);
                if (!Convert.IsDBNull(dr["MORDERBY"])) entity.MORDERBY = Convert.ToInt32(dr["MORDERBY"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 系统模块数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void ModuleExecute(string cmd)
        {
            DbExecute.Execute(cmd);
        }
    }
}
